package com.aizuda.boot.modules.business.comment.mapper;

import com.aizuda.boot.modules.business.comment.entity.CommentEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface CommentMapper extends BaseMapper<CommentEntity> {

    // 根据合同ID查询所有评论（包括所有层级）
    @Select("SELECT * FROM contract_comment WHERE contract_id = #{contractId} ORDER BY created_at ASC")
    List<CommentEntity> selectByContractId(@Param("contractId") Integer contractId);

    // 根据合同ID和评论类型查询评论
    @Select("SELECT * FROM contract_comment WHERE contract_id = #{contractId} AND comment_type = #{commentType} ORDER BY created_at ASC")
    List<CommentEntity> selectByContractIdAndType(@Param("contractId") Integer contractId, @Param("commentType") Integer commentType);
}